<?php

if(!defined('DEDEINC')) exit('Request Error!');

function lib_likeschool(&$ctag,&$refObj)
{
	global $dsql;
	
	//属性处理
	$attlist="row|12,titlelen|28,infolen|150,col|1,tablewidth|100,mytypeid|0,byabs|0,imgwidth|120,imgheight|90";
	FillAttsDefault($ctag->CAttribute->Items,$attlist);
	extract($ctag->CAttribute->Items, EXTR_SKIP);
	$revalue = '';
	
	//if(empty($tablewidth)) $tablewidth = 100;
	//if(empty($col)) $col = 1;
	//$colWidth = ceil(100/$col);
	//$tablewidth = $tablewidth."%";
	//$colWidth = $colWidth."%";
	
	$ids = array();
	$tids = array();
	
	if(!empty($refObj->Fields['tags'])) {
		$keyword = $refObj->Fields['tags'];
	}
	else {
		$keyword = ( !empty($refObj->Fields['keywords']) ? $refObj->Fields['keywords'] : '' );
	}
	
	$typeid = '';

	
	//$limitRow = 1;
	$keyword = '';
	if(!empty($refObj->Fields['school']))
	{
			
			$keyword = trim($refObj->Fields['school']);
			
	}
  
	if($keyword != '')
	{
	
			 $query = "Select aid,zsdm,yxmc,yxjj
		          from `#@__addonspec` where yxmc='$keyword' limit 1";
	
	}
	//$artlist = $query;
	$innertext = trim( $ctag->GetInnerText() );
	if($innertext=='') $innertext = GetSysTemplets('part_arclist.htm');

	$dsql->SetQuery($query);
	$dsql->Execute('al');
	$dtp2 = new DedeTagParse();
	$dtp2->SetNameSpace('field', '[', ']');
	$dtp2->LoadString($innertext);
	$GLOBALS['autoindex'] = 0;
	$line = $row;
	for($i=0; $i < $line; $i++)
	{

		for($j=0; $j < $col; $j++)
		{

			if($row = $dsql->GetArray("al"))
			{
				
				if(is_array($dtp2->CTags))
				{
					foreach($dtp2->CTags as $k=>$ctag)
					{
						if($ctag->GetName()=='array') {
							$dtp2->Assign($k,$row);
						}
						else {
							if(isset($row[$ctag->GetName()])) $dtp2->Assign($k,$row[$ctag->GetName()]);
							else $dtp2->Assign($k,'');
						}
					}
					$GLOBALS['autoindex']++;
				}
				$artlist .= $dtp2->GetResult()."\r\n";
			}
			//if hasRow
			else
			{
				$artlist .= '';
			}

		}
		//Loop Col

	}
	//loop line

	$dsql->FreeResult("al");
	return $artlist;
}
?>